<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>搭建环境 | lhx个人博客</title><meta name="keywords" content="前端基础CSS、Js、Vue、React、移动端、小程序、网络"><meta name="author" content="李汉鑫"><meta name="copyright" content="李汉鑫"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="1. 初始化项目1). 生成package.json     yarn init -y  2). 创建入口js: src&#x2F;index.js     console.log(&#39;Hello Webpack!&#39;)     document.getElementById(&#39;root&#39;).innerHTML &#x3D; &#39;&lt;h1&gt;Hello222&lt;&#x2F;h1&amp;g">
<meta property="og:type" content="article">
<meta property="og:title" content="搭建环境">
<meta property="og:url" content="http://example.com/Vue/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83/index.html">
<meta property="og:site_name" content="lhx个人博客">
<meta property="og:description" content="1. 初始化项目1). 生成package.json     yarn init -y  2). 创建入口js: src&#x2F;index.js     console.log(&#39;Hello Webpack!&#39;)     document.getElementById(&#39;root&#39;).innerHTML &#x3D; &#39;&lt;h1&gt;Hello222&lt;&#x2F;h1&amp;g">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg">
<meta property="article:published_time" content="2018-03-06T13:16:48.000Z">
<meta property="article:modified_time" content="2021-09-01T02:21:32.530Z">
<meta property="article:author" content="李汉鑫">
<meta property="article:tag" content="前端基础CSS、Js、Vue、React、移动端、小程序、网络">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg"><link rel="shortcut icon" href="https://img2.baidu.com/it/u=1328275982,1207856622&fm=26&fmt=auto&gp=0.jpg"><link rel="canonical" href="http://example.com/Vue/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '搭建环境',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-09-01 10:21:32'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="lhx个人博客" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://img2.baidu.com/it/u=203845187,735199026&amp;fm=26&amp;fmt=auto&amp;gp=0.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">31</div></a></div><div class="data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a></div><div class="data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">10</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">lhx个人博客</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">搭建环境</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="fa-fw post-meta-icon far fa-calendar-alt"></i><span class="post-meta-label">发表于</span><time datetime="2018-03-06T13:16:48.000Z" title="发表于 2018-03-06 21:16:48">2018-03-06</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Vue/">Vue</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="搭建环境"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="1-初始化项目"><a href="#1-初始化项目" class="headerlink" title="1. 初始化项目"></a>1. 初始化项目</h2><pre><code>1). 生成package.json
    yarn init -y

2). 创建入口js: src/index.js
    console.log(&#39;Hello Webpack!&#39;)
    document.getElementById(&#39;root&#39;).innerHTML = &#39;&lt;h1&gt;Hello222&lt;/h1&gt;&#39;

3). 创建页面文件: public/index.html
    &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;
</code></pre>
<h2 id="2-webpack基本使用"><a href="#2-webpack基本使用" class="headerlink" title="2. webpack基本使用"></a>2. webpack基本使用</h2><pre><code>1). 下载依赖包
    npm remove webpack webpack-cli -g
    npm install -D webpack webpack-cli
    npm install -D html-webpack-plugin

2). 创建webpack配置: webpack.config.js
    const path = require(&#39;path&#39;)
    const HtmlWebpackPlugin = require(&#39;html-webpack-plugin&#39;)
    
    function resolve(dir) &#123;
      return path.resolve(__dirname, dir)
    &#125;
    module.exports = &#123;
      // 模式: 生产环境
      // mode: &#39;production&#39;,

      // 入口
      entry: &#123;
        app: resolve(&#39;src/index.js&#39;)
      &#125;,
      // 出口(打包生成js)
      output: &#123;
        path: resolve(&#39;dist&#39;),
        filename: &#39;js/[name].bundle.js&#39;,
      &#125;,
      // 模块加载器
      module: &#123;
        rules: [

        ]
      &#125;,
      // 插件
      plugins: [
        new HtmlWebpackPlugin(&#123;
          template: &#39;public/index.html&#39;,
          filename: &#39;index.html&#39;
        &#125;)
      ]
    &#125;

3). 生成环境打包并运行
    配置打包命令:  &quot;build&quot;: &quot;webpack --mode production&quot;
    打包项目: yarn build
    运行打包项目: serve dist  (第一次全局下载serve: npm install -g serve)
</code></pre>
<h2 id="3-开发环境运行"><a href="#3-开发环境运行" class="headerlink" title="3. 开发环境运行"></a>3. 开发环境运行</h2><pre><code>1). 现在的问题:
    每次修改项目代码后, 必须重新打包, 重新运行

2). 下载依赖包
    npm install -D webpack-dev-server

3). 配置开发服务器
    devServer: &#123;
      open: true, // 自动打开浏览器
        port: 8080, // 指定启动服务器的端口号
      stats: &#39;errors-only&#39;, // 只输出错误日志
    &#125;,

4). 配置开启source-map调试
    devtool: &#39;cheap-module-eval-source-map&#39;,

5). 开发环境运行
    配置命令: &quot;dev&quot;: &quot;webpack-dev-server --mode development&quot;
    执行命令: npm run dev
</code></pre>
<h2 id="4-打包处理-ES6-CSS-图片"><a href="#4-打包处理-ES6-CSS-图片" class="headerlink" title="4. 打包处理 ES6/CSS/图片"></a>4. 打包处理 ES6/CSS/图片</h2><pre><code>1). 处理ES6
    a. 下载依赖包
        npm install -D babel-loader @babel/core @babel/preset-env
    b. 配置
        &#123;
          test: /\.js$/,
          //exclude: /(node_modules|bower_components)/,
          include: resolve(&#39;src&#39;),
          use: &#123;
            loader: &#39;babel-loader&#39;,
            options: &#123;
              presets: [&#39;@babel/preset-env&#39;]
            &#125;
          &#125;
        &#125;
    c. 理解babel的plugin与preset
        babel本身不编译ES6的语法
        babel需要基于它的plugin来做ES语法的编译
        每个语法都一个对应的babel plugin来编译对应的语法
        一个babel preset包是包含多个常用的babel plugin的集合包
        好处: 便于管理, 简化配置

2). 处理CSS
    a. 下载依赖包
        npm install -D css-loader style-loader
    b. 配置
        &#123;
          test: /\.css$/,
          use: [&#39;style-loader&#39;, &#39;css-loader&#39;], // 多个loader从右到左处理
        &#125;

3). 处理图片
    a. 下载依赖包
        npm install -D url-loader@2.3.0 file-loader@4.3.0
    b. 配置
        &#123;
          test: /\.(png|jpe?g|gif|svg)$/,
          loader: &#39;url-loader&#39;,
          options: &#123;
            limit: 1000,
            name: &#39;img/[name].[ext]&#39; // 相对于output.path
          &#125;
        &#125;
4). 测试
    a. 添加图片: src/assets/imgs/logo.png
    b. 添加css: src/assets/css/my.css
        img &#123;
          width: 200px;
          height: 200px;
        &#125;
    c. index.js
        import logo from &#39;./assets/imgs/logo.png&#39;
        import  &#39;./assets/css/my.css&#39;

        const image = new Image()
        image.src = logo
        document.body.appendChild(image)
        document.getElementById(&#39;root&#39;).innerHTML = &#39;&lt;h1&gt;Hello222&lt;/h1&gt;&#39;
</code></pre>
<h2 id="5-搭建vue的环境"><a href="#5-搭建vue的环境" class="headerlink" title="5. 搭建vue的环境"></a>5. 搭建vue的环境</h2><pre><code>0). 文档:
    https://vue-loader.vuejs.org/zh/

1). 下载依赖包:
    npm install -S vue
    npm install -D vue-loader vue-template-compiler

2). 配置
    const VueLoaderPlugin = require(&#39;vue-loader/lib/plugin&#39;)

    &#123;
      test: /\.vue$/,
      include: resolve(&#39;src&#39;), // 只对src下的vue文件处理
      loader: &#39;vue-loader&#39;
    &#125;

    &#123;
      test: /\.css$/,
      use: [&#39;vue-style-loader&#39;, &#39;css-loader&#39;],
    &#125;

    new VueLoaderPlugin()

    // 引入模块的解析
    resolve: &#123;
      extensions: [&#39;.js&#39;, &#39;.vue&#39;, &#39;.json&#39;], // 可以省略的后缀名
      alias: &#123; // 路径别名(简写方式)
        &#39;vue$&#39;: &#39;vue/dist/vue.esm.js&#39;,  // 如果是引入&#39;vue&#39;, 加载带编译的版本
        &#39;@&#39;: resolve(&#39;src&#39;),
      &#125;
    &#125;

3). 编码: 
    src/App.vue
    src/index.js
</code></pre>
<h2 id="6-解决开发环境ajax请求跨域问题"><a href="#6-解决开发环境ajax请求跨域问题" class="headerlink" title="6. 解决开发环境ajax请求跨域问题"></a>6. 解决开发环境ajax请求跨域问题</h2><pre><code>1). 利用webpack-dev-server进行请求代理转发
    webpack-dev-server内部利用http-proxy-middle包对特定请求进行转发操作
2). 配置:
    devServer: &#123;
      proxy: &#123;
        // 处理以/api开头路径的请求
        // &#39;/api&#39;: &#39;http://localhost:4000&#39;
        &#39;/api&#39;: &#123;
          target: &#39;http://localhost:4000&#39;, // 转发的目标地址
          pathRewrite: &#123;
            &#39;^/api&#39; : &#39;&#39;  // 转发请求时去除路径前面的/api
          &#125;,
          changeOrigin: true, // 支持跨域
        &#125;
      &#125;
    &#125;
</code></pre>
<h2 id="7-配置async-await的编译环境"><a href="#7-配置async-await的编译环境" class="headerlink" title="7. 配置async/await的编译环境"></a>7. 配置async/await的编译环境</h2><pre><code>1). 下载包
    yarn add @babel/polyfill
2). 配置
    entry: &#123;
      xxx: [&#39;@babel/polyfill&#39;, resolve(&#39;src/index.js&#39;)]
    &#125;,
</code></pre>
<h2 id="8-解决mint-ui按需引入配置异常的问题"><a href="#8-解决mint-ui按需引入配置异常的问题" class="headerlink" title="8. 解决mint-ui按需引入配置异常的问题"></a>8. 解决mint-ui按需引入配置异常的问题</h2><pre><code>1). 文档上的配置
    &quot;plugins&quot;: [
      [&quot;component&quot;, [
        &#123;
          &quot;libraryName&quot;: &quot;mint-ui&quot;,
          &quot;style&quot;: true
        &#125;
      ]]
    ]
2). 异常信息:  
    Error: .plugins[0][1] must be an object, false, or undefined
3). 原因:
    文档编写时, 是根据老的babel版本编写的, 新版本的babel配置有变化
    以前是数组, 现在只能是对象
4). 修正:
    &quot;plugins&quot;: [
      [&quot;component&quot;, &#123;
          &quot;libraryName&quot;: &quot;mint-ui&quot;,
          &quot;style&quot;: true
      &#125;]
    ]
</code></pre>
<h2 id="9-解决history模式路由请求404的问题"><a href="#9-解决history模式路由请求404的问题" class="headerlink" title="9. 解决history模式路由请求404的问题"></a>9. 解决history模式路由请求404的问题</h2><pre><code>devServer: historyApiFallback: true, // 任意的 404 响应都被替代为 index.html
output: publicPath: &#39;/&#39;, // 引入打包的文件时路径以/开头
</code></pre>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">李汉鑫</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/Vue/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83/">http://example.com/Vue/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">lhx个人博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/CSS%E9%87%8D%E7%82%B9/Flex%E5%B8%83%E5%B1%80/"><img class="prev-cover" src="https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Flex布局</div></div></a></div><div class="next-post pull-right"><a href="/Vue/%E8%84%9A%E6%89%8B%E6%9E%B6/"><img class="next-cover" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">脚手架</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://img2.baidu.com/it/u=203845187,735199026&amp;fm=26&amp;fmt=auto&amp;gp=0.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">李汉鑫</div><div class="author-info__description">前端基础CSS、Js、Vue、React、移动端、小程序、网络</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">31</div></a></div><div class="card-info-data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a></div><div class="card-info-data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">10</div></a></div></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">个人网站,欢迎交流</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%88%9D%E5%A7%8B%E5%8C%96%E9%A1%B9%E7%9B%AE"><span class="toc-number">1.</span> <span class="toc-text">1. 初始化项目</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-webpack%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8"><span class="toc-number">2.</span> <span class="toc-text">2. webpack基本使用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E8%BF%90%E8%A1%8C"><span class="toc-number">3.</span> <span class="toc-text">3. 开发环境运行</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E6%89%93%E5%8C%85%E5%A4%84%E7%90%86-ES6-CSS-%E5%9B%BE%E7%89%87"><span class="toc-number">4.</span> <span class="toc-text">4. 打包处理 ES6&#x2F;CSS&#x2F;图片</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E6%90%AD%E5%BB%BAvue%E7%9A%84%E7%8E%AF%E5%A2%83"><span class="toc-number">5.</span> <span class="toc-text">5. 搭建vue的环境</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-%E8%A7%A3%E5%86%B3%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83ajax%E8%AF%B7%E6%B1%82%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98"><span class="toc-number">6.</span> <span class="toc-text">6. 解决开发环境ajax请求跨域问题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-%E9%85%8D%E7%BD%AEasync-await%E7%9A%84%E7%BC%96%E8%AF%91%E7%8E%AF%E5%A2%83"><span class="toc-number">7.</span> <span class="toc-text">7. 配置async&#x2F;await的编译环境</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8-%E8%A7%A3%E5%86%B3mint-ui%E6%8C%89%E9%9C%80%E5%BC%95%E5%85%A5%E9%85%8D%E7%BD%AE%E5%BC%82%E5%B8%B8%E7%9A%84%E9%97%AE%E9%A2%98"><span class="toc-number">8.</span> <span class="toc-text">8. 解决mint-ui按需引入配置异常的问题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-%E8%A7%A3%E5%86%B3history%E6%A8%A1%E5%BC%8F%E8%B7%AF%E7%94%B1%E8%AF%B7%E6%B1%82404%E7%9A%84%E9%97%AE%E9%A2%98"><span class="toc-number">9.</span> <span class="toc-text">9. 解决history模式路由请求404的问题</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/%E7%A7%BB%E5%8A%A8%E7%AB%AF/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" title="移动端"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="移动端"/></a><div class="content"><a class="title" href="/%E7%A7%BB%E5%8A%A8%E7%AB%AF/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" title="移动端">移动端</a><time datetime="2021-06-07T09:21:39.000Z" title="发表于 2021-06-07 17:21:39">2021-06-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="小程序基础"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="小程序基础"/></a><div class="content"><a class="title" href="/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="小程序基础">小程序基础</a><time datetime="2021-05-03T05:20:10.000Z" title="发表于 2021-05-03 13:20:10">2021-05-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E7%BD%91%E7%BB%9C/http%E5%8D%8F%E8%AE%AE%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B%E5%92%8C%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B/" title="http协议三次握手和四次挥手"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="http协议三次握手和四次挥手"/></a><div class="content"><a class="title" href="/%E7%BD%91%E7%BB%9C/http%E5%8D%8F%E8%AE%AE%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B%E5%92%8C%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B/" title="http协议三次握手和四次挥手">http协议三次握手和四次挥手</a><time datetime="2020-10-25T13:40:49.000Z" title="发表于 2020-10-25 21:40:49">2020-10-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E7%BD%91%E7%BB%9C/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E5%9C%B0%E5%9D%80%E6%A0%8F%E8%BE%93%E5%85%A5url%E7%84%B6%E5%90%8E%E6%95%B2%E5%87%BB%E5%9B%9E%E8%BD%A6%E4%B9%8B%E5%90%8E%E9%83%BD%E5%81%9A%E4%BA%86%E4%BB%80%E4%B9%88/" title="在浏览器地址栏输入url然后敲击回车之后都做了什么"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="在浏览器地址栏输入url然后敲击回车之后都做了什么"/></a><div class="content"><a class="title" href="/%E7%BD%91%E7%BB%9C/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E5%9C%B0%E5%9D%80%E6%A0%8F%E8%BE%93%E5%85%A5url%E7%84%B6%E5%90%8E%E6%95%B2%E5%87%BB%E5%9B%9E%E8%BD%A6%E4%B9%8B%E5%90%8E%E9%83%BD%E5%81%9A%E4%BA%86%E4%BB%80%E4%B9%88/" title="在浏览器地址栏输入url然后敲击回车之后都做了什么">在浏览器地址栏输入url然后敲击回车之后都做了什么</a><time datetime="2020-10-24T14:10:19.000Z" title="发表于 2020-10-24 22:10:19">2020-10-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E7%BD%91%E7%BB%9C/%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E6%8A%A5%E6%96%87/" title="请求响应报文"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="请求响应报文"/></a><div class="content"><a class="title" href="/%E7%BD%91%E7%BB%9C/%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E6%8A%A5%E6%96%87/" title="请求响应报文">请求响应报文</a><time datetime="2020-10-24T12:21:39.000Z" title="发表于 2020-10-24 20:21:39">2020-10-24</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By 李汉鑫</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>